package org.brian.blueirisviewer.util;

public class OSDetection
{
	private static String OS = System.getProperty("os.name").toLowerCase();
	public static String arch = System.getProperty("os.arch").toLowerCase();
	
	public static boolean is64Bit()
	{
		if(arch == null)
			return false;
		if(arch.contains("64"))
			return true;
		return false;
		// Alternative method:
		// return "64".equals(System.getProperty("sun.arch.data.model"))
	}
	
	public static boolean isWindows()
	{
		return (OS.indexOf("win") >= 0);
	}

	public static boolean isMac()
	{
		return (OS.indexOf("mac") >= 0);
	}

	public static boolean isUnix()
	{
		return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0);
	}

	public static boolean isSolaris()
	{
		return (OS.indexOf("sunos") >= 0);
	}

	public static String getOS()
	{
		if (isWindows())
		{
			return "win";
		}
		else if (isMac())
		{
			return "osx";
		}
		else if (isUnix())
		{
			return "uni";
		}
		else if (isSolaris())
		{
			return "sol";
		}
		else
		{
			return "err";
		}
	}
}